As disclosed in Patent Documents 1 to 4 and Non-patent Document 1, a metric learning apparatus of the related art using a classification on the basis of k-nearest neighbor algorithm improves accuracy of the k-nearest neighbor classification by learning a metric in which the distance between patterns in the same category is small and the distance between patterns in different categories is large.